import { get } from './request'

export interface AppVersionCheckParams {
  platform: string
  versionCode: number
  channel?: string
  versionName?: string
}

export interface AppVersionCheckResult {
  hasUpdate: boolean
  updateType?: 'wgt' | 'apk' | 'ipa' | string
  versionName?: string
  versionCode?: number
  downloadUrl?: string
  fileSize?: number
  fileMd5?: string
  forceUpdate?: boolean
  minVersion?: string
  updateDesc?: string
  updateNotes?: string[]
}

/**
 * 检查 App 是否存在可用更新
 */
export function checkAppVersion(params: AppVersionCheckParams) {
  return get<AppVersionCheckResult>('/app/version/check', params)
}
